package com.yanqu.road.logic.sort.yrank;

import com.yanqu.road.entity.rank.yrank.UnionYRank;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.Comparator;
import java.util.Objects;

/**
 * 小马快跑商会排行榜排序规则
 */
public class UnionYRankHorseRunSort implements Comparator<UnionYRank> {

    @Override
    public int compare(UnionYRank o1, UnionYRank o2) {
        //值大的在前面
        if (!Objects.equals(o1.getValue(), o2.getValue())) {
            return o2.getValue().compareTo(o1.getValue());
        }

        //赚钱大的在前面
        int abilityCompare = o2.getUnionBaseInfo().getTotalPatronsAbility().compareTo(o1.getUnionBaseInfo().getTotalPatronsAbility());
        if (abilityCompare != 0){
            return abilityCompare;
        }
        return Long.compare(o1.getUpdateTime(), o2.getUpdateTime());
    }

}